package com.woai.vichat.main.presenter;
import android.app.Activity;

import com.woai.vichat.base.presenter.BasePresenter;
import com.woai.vichat.main.act.MyProfileFrgm;
import com.woai.common.util.IntentUtils;
import com.woai.common.util.ToastUtil;


import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response;
import com.woai.common.http.BaseResponse;
import com.woai.common.http.DialogCallback;
import com.woai.common.http.HttpUtil;
import com.woai.vichat.main.entity.MyProfileModel;
import com.woai.vichat.cons.ViCons;
import com.woai.vichat.cons.ViURL;
import com.woai.vichat.sp.ViSp;

/**
 * MyProfilePresenter
 * Created on 2018-06-29 15:59:38.
 * @author WuGefei
 */
public class MyProfilePresenter extends BasePresenter<MyProfileFrgm> {


    public void request(final Activity activity){
        HttpParams params = new HttpParams();
        //HTTP请求参数
        params.put("token", ViCons.SYSTEM_TOKEN);
        params.put("login_uid", ViSp.getUID());
        HttpUtil.get(ViURL.VIDEO_LIST, this, params, new DialogCallback<BaseResponse<MyProfileModel>>(activity) {
            @Override
            public void onSuccess(Response<BaseResponse<MyProfileModel>> response) {

                ToastUtil.showLong(activity, response.body().getMsg());
                int errcode = response.body().getCode();
                if (errcode == 0) {//请求成功且业务成功
                    //处理HTTP返回值
                    getContext().bindData(response.body().getData());
                }
                else if(errcode == 10701){
                    //getContext().disableLoadMore();
                }
                else {//业务失败
                    ToastUtil.showShort(activity, response.body().getMsg());
                }
            }

            @Override
            public void onError(Response<BaseResponse<MyProfileModel>> response) {
                super.onError(response);
                //HTTP请求错误
                ToastUtil.showShort(activity, response.getException().getMessage());
            }
        });
    }

}